<?php
/**
 * 升级红人大礼包
 */
namespace App\Controller\Goods;
use Common\Controller\App\SignController;
use Common\Model\ProductSkuModel;

class RedController extends SignController{

    /**
     * 升级红人大礼包列表
     */
    public function lists(){
        $model = new ProductSkuModel();
        $list = $model->where("catid=1011 and status=1")->field("hongrenname,hongrenpic,id,pname,ms_stock_supplierid,ms_entrepot_supplierid,ms_direct_supplierid")->select();
        foreach($list as $k=>$v){

        }
        foreach($list as $k=>$v){
            if(!empty($v['hongrenname'])){
                $list[$k]['hongrenname'] = explode(',',$v['hongrenname']);
            }else{
                $list[$k]['hongrenname'] = [];
            }
            $ways = [];
            $way = $model->getShipmentsWay($v['id'], 1, $v['ms_stock_supplierid']);
            if (!empty($way)) {
                $ways[] = $way;
            }

            //是否存在于保税仓库
            $warehouseType = 1;
            $way = $model->getShipmentsWay($v['id'], 2, $v['ms_entrepot_supplierid']);
            if (!empty($way)) {
                $ways[] = $way;
            }

            //是否存在于直邮仓
            $warehouseType = 1;
            $way = $model->getShipmentsWay($v['id'], 3, $v['ms_direct_supplierid']);
            if (!empty($way)) {
                $ways[] = $way;
            }
            //$pic = explode(',',$v['pic']);
           // $list[$k]['pic'] = $pic[0];
            $list[$k]['supplierId'] = $ways[0]['supplierId'];
            $list[$k]['stock'] = $ways[0]['stock'];
            $list[$k]['warehouseType'] = $ways[0]['warehouseType'];
        }
        $this->ajaxReturn(['code'=>200,'list'=>$list]);
    }
}